const app = getApp();
Page({
  data: {
    tanchuang_1: false, //弹窗-1
    tanchaung_2: false, //弹窗-2
  },
  onLoad:function(){
    var openid=wx.getStorageSync('openid');
    var that = this;
    wx.request({
      url: 'https://www.mamingwang.cn/api/adds/Financialbangcai',
      data:{
        openid:openid
      },
      method:"post",
      success(res){
        that.setData({
          message:res.data.data
        })
      }
    })
  },
  //跳转到随你压
  goSNY: function() {
    wx.redirectTo({
      url: '../suiNiYa/suiNiYa',
    })
  },
  //弹窗仿点击
  preventTouchMove: function() {},
  //咨询打电话
  tellPhone: function (e) {
    var that = this;
    var openid = wx.getStorageSync('openid');
    var tel = e.currentTarget.dataset.tel;
    wx.request({
      url: 'https://www.mamingwang.cn/api/adds/bangnicai',
      data: {
        openid: openid,
        flg: 2
      },
      method: "post",
      success(res) {
        wx.makePhoneCall({
          phoneNumber: that.data.message[0].tel,
          success(res) { }
        })
      }
    })
  },
  //弹窗-1 显示
  tanchuang: function() {
    console.log(1)
    this.setData({
      tanchuang_1: !this.data.tanchuang_1
    })
  },
  //弹窗-1 取消
  cancel: function() {
    this.setData({
      tanchuang_1: !this.data.tanchuang_1
    })
  },
  //弹窗-1 确定
  confirm: function () {
    var that = this;
    var openid = wx.getStorageSync('openid');
    wx.request({
      url: 'https://www.mamingwang.cn/api/adds/bangnicai',
      data: {
        openid: openid,
        flg: 0
      },
      method: "post",
      success(res) {
        if (res.data.code == 0) {
          wx.showToast({
            title: '操作失败',
            icon: "none",
            duration: 1500,
            mask:true
          })
          that.setData({
            tanchuang_1: !that.data.tanchuang_1
          })
        } else {
          that.setData({
            tanchuang_1: !that.data.tanchuang_1,
            tanchaung_2: !that.data.tanchaung_2
          })
        }
      }
    })
  },
  //弹窗-2 确定
  sure: function() {
    this.setData({
      tanchaung_2: !this.data.tanchaung_2
    })
  },
})